Skip to content

Conversation

@jerrymhuang
Copy link
Collaborator

@jerrymhuang jerrymhuang commented Apr 18, 2025

bf_new_loss

Fixed and refined bf.diagnostics.plots.loss:

  • Replace the moving average with an exponential moving average and make it functional and by default;
  • Provide the user with a new set of customization, including moving average window (span), color maps, markers, and grid;
  • Make the validation loss a viridis gradient line.

This version of loss plot also propagates to the workflow object.

@jerrymhuang jerrymhuang requested a review from LarsKue April 18, 2025 19:54
@codecov
Copy link

codecov bot commented Apr 18, 2025

Codecov Report

Attention: Patch coverage is 40.42553% with 28 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
bayesflow/utils/plot_utils.py 21.21% 26 Missing ⚠️
bayesflow/diagnostics/plots/loss.py 85.71% 2 Missing ⚠️
Files with missing lines Coverage Δ
bayesflow/workflows/basic_workflow.py 61.40% <ø> (ø)
bayesflow/diagnostics/plots/loss.py 92.68% <85.71%> (+20.46%) ⬆️
bayesflow/utils/plot_utils.py 68.42% <21.21%> (-19.24%) ⬇️

... and 15 files with indirect coverage changes

Copy link
Contributor

@LarsKue LarsKue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I will add the changes that I proposed myself.

LarsKue added 3 commits April 19, 2025 16:38
Simplified the loss plotting code by consolidating duplication and aligning the handling of smoothing logic. Removed unused arguments like markers and colormap, reducing potential confusion in the API. Updated comments and improved code readability for maintainability.
@LarsKue
Copy link
Contributor

LarsKue commented Apr 19, 2025

Although it is very pretty, I am removing the gradient line for now, until we have resolved how we can reliably add it to the legend. I also simplified the rest of the code and fixed an issue with the smoothing factor being applied the wrong way around.

@LarsKue LarsKue self-requested a review April 19, 2025 21:01
LarsKue added 8 commits April 20, 2025 14:57
Removed an unnecessary `plt.show()` call in the test to streamline the code. Added a `pytest_runtest_teardown` hook to automatically close all matplotlib figures after tests to prevent resource leaks and improve test isolation.
@LarsKue LarsKue merged commit bc90d05 into main Apr 20, 2025
14 of 15 checks passed
@LarsKue LarsKue deleted the enhanced-loss branch April 20, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants